package org.feiye.studyday25;

import java.io.*;

public class FileReaderTest {
	// 字符输入流(解决编码问题)
	public static void main(String[] args) {
		InputStream i = null;
		Reader r = null;
		try {
			i = new FileInputStream("F:\\网盘最新地址.txt");
			r = new InputStreamReader(i, "gbk");
			int ch = 0;
			while ((ch = r.read()) > -1) {
				System.out.print((char) ch);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (r != null)
				try {
					r.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			if (i != null)
				try {
					i.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
//		Reader r = null;
//		try {
//			r = new FileReader("F:\\\\叶飞io测试\\\\字符输入输出流\\\\我的爱好.txt");
//			char[] c = new char[1024];
//			int ch = 0;
//			while ((ch = r.read(c)) > -1) {
////				for (int i = 0; i < ch; i++) {
////					System.out.print(c[i]);
////				}
//				String s = new String(c, 0, ch);
//				System.out.println(s);
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			if (r != null)
//				try {
//					r.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//		}

	}

}
